package com.zndroid.layertree.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.zndroid.layertree.R;
import com.zndroid.layertree.model.CData;
import com.zndroid.layertree.model.GData;
import com.zndroid.layertree.vh.CVH;
import com.zndroid.layertree.vh.GVH;

public class BaseExpandableAdapter extends ABaseExpandableAdapter<GData, CData, GVH, CVH> {
    public BaseExpandableAdapter(Context context) {
        super(context);
    }

    @Override
    protected int bindGroupItemViewId() {
        return R.layout.layout_group;
    }

    @Override
    protected int bindChildItemViewId() {
        return R.layout.layout_child;
    }

    @NonNull
    @Override
    protected GVH bindGroupVH(View itemView, int type, ViewGroup parent) {
        return new GVH(itemView);
    }

    @NonNull
    @Override
    protected CVH bindChildVH(View itemView, int type, ViewGroup parent) {
        return new CVH(itemView);
    }

    @Override
    protected void onBindGroupData(GVH gvh, GData group, int groupPosition) {
        gvh.nameTextView.setText(group.getName());
    }

    @Override
    protected void onBindChildData(CVH cvh, CData child, int groupPosition, int childPosition) {
        cvh.nameTextView.setText(child.getName());
        cvh.ageTextView.setText(child.getAge() + "");
    }
}
